﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

using Vitruvian.Logging;
using Vitruvian.Testing;

namespace SpotItComponents
{
    /// <summary>
    /// DeckSetupDirectorForRandomSymbol
    /// 
    /// Use this setup director create deck from randomly selected symbols in the symbol set.
    /// </summary>
    [ContainsTests("Components.DeckSetupDirector")]
    public class DeckSetupDirectorUsingRandomSymbols : DeckSetupDirector
    {
        static private Random rnd = new Random(DateTime.Now.Millisecond);

        protected override Universe FindUniverseBasedOnSymbols()
        {
            return Universe.FindUniverseBasedOnSymbols(FromSymbolSet.Symbols.Count);
        }

        protected override bool SelectSymbols(int NumberOfSymbols)
        {
            return (NumberOfSymbols <= FromSymbolSet.Symbols.Count);
        }

        protected override Symbol GetSymbolByIndex(int index)
        {
            return FromSymbolSet.Symbols[index];
        }

        #region Unit Test Cases
#if (DEBUG)
        [Test(1)]
        private void Test_Deck_Setup()
        {
            Image backImage = new Bitmap("../../../Symbols/Background-1.jpg");
            Deck deck1 = new Deck("Test Deck", true, backImage);
            Assert.IsNotEqual(Guid.Empty, deck1.Id);
            Assert.Equals("My Favorite Deck", deck1.Label);
            Assert.IsTrue(deck1.IsPrivate);
            Assert.IsNotNull(deck1.Categories);
            Assert.Equals(0, deck1.Categories.Count);
            Assert.IsNotNull(deck1.BackImage);

            DeckSetupDirectorUsingRandomSymbols director = new DeckSetupDirectorUsingRandomSymbols();
            director.FromSymbolSet = SetupTestSymbolSet();
            director.TargetDeck = deck1;
            director.Setup();

            Assert.Equals(31, deck1.Cards.Count);
        }

        private SymbolSet SetupTestSymbolSet()
        {
            SymbolSet ss1 = new SymbolSet("My Favorite Symbols", true);
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Alligator", new Bitmap("../../../Symbols/Alligator.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Baby Penguin", new Bitmap("../../../Symbols/BabyPenguin.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Bat", new Bitmap("../../../Symbols/Bat.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Bear", new Bitmap("../../../Symbols/Bear.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Beaver", new Bitmap("../../../Symbols/Beaver.jpg")));

            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Bison", new Bitmap("../../../Symbols/Bison.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Bow", new Bitmap("../../../Symbols/Cow.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Crab", new Bitmap("../../../Symbols/Crab.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Dear", new Bitmap("../../../Symbols/Dear.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Dog", new Bitmap("../../../Symbols/Dog.jpg")));

            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Dolphin", new Bitmap("../../../Symbols/Dolphin.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Elephant", new Bitmap("../../../Symbols/Elephant.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Green Fish", new Bitmap("../../../Symbols/Fish-1.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Orange Fishes", new Bitmap("../../../Symbols/Fish-2.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Alligator", new Bitmap("../../../Symbols/Horse.jpg")));

            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Kangaroo", new Bitmap("../../../Symbols/Kangaroo.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Koala", new Bitmap("../../../Symbols/Koala.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Lion", new Bitmap("../../../Symbols/Lion.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Tiger", new Bitmap("../../../Symbols/Tiger.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Lizzard", new Bitmap("../../../Symbols/Lizzard.jpg")));

            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Monkey", new Bitmap("../../../Symbols/Monkey.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Octopus", new Bitmap("../../../Symbols/Octopus.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Owl", new Bitmap("../../../Symbols/Owl.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Penguin", new Bitmap("../../../Symbols/Penguin.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Shark", new Bitmap("../../../Symbols/Shark.jpg")));

            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Snake", new Bitmap("../../../Symbols/Snake.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Squirrel", new Bitmap("../../../Symbols/Squirrel.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Squirrel-2", new Bitmap("../../../Symbols/Squirrel-2.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Tucan", new Bitmap("../../../Symbols/Tucan.jpg")));
            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Whale", new Bitmap("../../../Symbols/Whale.jpg")));

            ss1.AddSymbol(Symbol.CreateSymbolWithLabelImage("Zebra", new Bitmap("../../../Symbols/Zebra.jpg")));

            Assert.IsEqual(31, ss1.Symbols.Count);

            return ss1;
        }

#endif
        #endregion

    }
}
